import React, { Component } from 'react'

export default class App extends Component {
  constructor(props) {
      super(props)
      console.log('---constructor')
    }
  state = {
    msg: '🐂'
  }
  handleClick = () => {
    this.setState({
      msg: '🐖'
    })
  }

  static getDerivedStateFromProps(props, state){
    console.log('---getDerivedStateFromProps')
    return null
  }
  shouldComponentUpdate(nextProps, nextState){
    console.log('---shouldComponentUpdate')
    // return true
    return false
  }
  render() {
    console.log('---render')
    return (
      <div>
        <h1>{this.state.msg}</h1>
        <button onClick={this.handleClick}>更新</button>
      </div>
    )
  }
  componentDidMount() {
    console.log('---componentDidMount')
  }
  getSnapshotBeforeUpdate(preProps, preState){
    console.log('---getSnapshotBeforeUpdate')
    return null
  }
  componentDidUpdate(preProps, preState, snapshot) {
    console.log('---componentDidUpdate')
  }
}
